package com.starblink.basic.route

import android.net.Uri
import android.os.Parcelable
import kotlinx.android.parcel.Parcelize

object RoutePage {

    /**
     * 兼容原flutter的各种外链或scHeme协议跳转
     */
    fun getRealRouteStrFlutterTransNative(path: String, params: Uri? = null): String {
        var transPath = path

        when (path) {
            "/home" -> {
                transPath = Main.MAIN_ACTIVITY
            }

            "/post_detail" -> {
                //处理内容详情场景
                transPath = Main.MAIN_ACTIVITY
//                transPath = Post.PAGE_PIC
//                params?.let {
//                    if (it.getQueryParameter("type") == "1") {
//                        transPath = Post.PAGE_PIC
//                    } else if (it.getQueryParameter("type") == "2") {
//                        transPath = PostVideo.PAGE_VIDEO
//                    }
//                }

            }

            "/post_video_detail" -> {
                //处理内容视频详情场景
                transPath = Main.MAIN_ACTIVITY
//                transPath = PostVideo.PAGE_VIDEO
            }

            "/post_pic_detail" -> {
                //话题
                transPath = Main.MAIN_ACTIVITY
//                transPath = Post.PAGE_PIC
            }

            "/topic_detail" -> {
                //话题
//                if(ActivityStackManage.currentActivity())
                transPath = Main.MAIN_ACTIVITY
//                transPath = Post.PAGE_TOPIC
            }

            "/hashtag_detail" -> {
                //hashtag
                transPath = Main.MAIN_ACTIVITY
//                transPath = Post.PAGE_HASHTAG
            }

            "/recommend_stores_page" -> {
                transPath = Store.PAGE_HOME_RECOMMEND
            }

            "/account", "/objective_mine_account", "/own_mine_account" -> {
                //个人中心首页
                transPath = Main.MAIN_ACTIVITY
//                transPath = Mine.PERSON_HOME
            }

            "/home_camera" -> {
                //相机
                transPath = ImageSearch.PAGE_CAMERA
            }

            "/h5" -> {
                //web
                transPath = Web.PAGE_GLOBAL_H5
            }

            "/search" -> {
                //搜索页面
                transPath = Search.PAGE_SEARCH
            }

            "/product_web_link" -> {
                //商品web
                transPath = Product.PAGE_LINK
            }

            "/recommend_similar_products" -> {
                //商品详情
                transPath = Product.PAGE_DETAIL
            }

            "/oneScreenOneCard" -> {
                //商品详情
                transPath = Product.PAGE_DETAIL
            }

            "/stores_home_page" -> {
                //商铺主页
                transPath = Store.PAGE_HOME
            }

            "/stores_link_page" -> {
                //商铺外链页
                transPath = Store.PAGE_LINK
            }

            "/stores_manage_page" -> {
                //商铺管理页
                transPath = Store.PAGE_MANAGE
            }

            "/user_login" -> {
                //登录页
                transPath = Login.SING_IN
            }

            "/wish_list_route" -> {
                //心愿单详情
                transPath = Wishlist.WISHLIST_DETAILS
            }

            "/brand_collections_detail" -> {
                //品牌合集详情
                transPath = Brand.BRAND_COLLECTION
            }

            "/brandOutletsPage" -> {
                //品牌奥莱详情
                transPath = Brand.BRAND_DETAIL
            }

            else -> {
//                transPath = "/error$transPath"
            }
        }
        return transPath
    }


    object Web {

        const val GROUP = "/web"

        /**
         * 全局H5
         */
        const val PAGE_GLOBAL_H5 = "${GROUP}/h5"

        //二维码扫描
        const val PAGE_GLOBAL_SCAN = "${GROUP}/scan"

        const val ARG_WHITE_LIST = "with_white_list"

        const val ARG_AUTO_JUMP = "ifAutoJump" //是否自动跳转

        const val ARG_URL = "url"
        const val ARG_TITLE = "title"
        const val ARG_USECACHE = "ifUseCache" //是否使用缓存
        const val ARG_STRICTMODE = "ifStrictMode" //是否宽松模式 会放UA
        const val PARAMS_APP_TITLE = "title" //标题
        const val PARAMS_APP_CLEAR = "appClear" //缓存是否需要清理 页面关闭时清理
        const val PARAMS_APP_USECACHE = "appUseCache" //是否使用缓存
        const val PARAMS_APP_SHOWNAV = "showNav" //是否使用原生标题栏
        const val SPM_CNT = "spmCnt" //埋点前置点
    }


    /**
     * home
     */
    object Main {
        const val GROUP = "/main"
        const val MAIN_ACTIVITY = "$GROUP/main_activity"
        const val HOME_FRAGMENT = "$GROUP/home_fragment"
    }

    object Login {

        const val GROUP = "/login"

        const val SING_IN = "$GROUP/user_login" //flutter
        const val SING_IN_WITH_EMAIL = "$GROUP/sign_in_with_email" //flutter 无路由
        const val SING_IN_WITH_GOOGLE = "$GROUP/sign_in_with_google"//flutter 无路由
        const val SING_IN_WITH_FACE_BOOK = "$GROUP/sign_in_with_face_book"//flutter 无路由

        const val CREATE_ACCOUNT_INPUT_EMAIL = "$GROUP/create_account_input_email" //创建账户输入邮箱
        const val CREATE_ACCOUNT_INPUT_PSW = "$GROUP/create_account_input_psw" //创建账户输入密码
        const val CREATE_ACCOUNT_REGISTER = "$GROUP/create_account_register" //创建账户输入用户名，并注册登录

        const val ACCOUNT_MANAGEMENT = "$GROUP/setting_my_account" //flutter
        const val CHANGE_BOUND_EMAIL_INPUT_EMAIL =
            "$GROUP/change_bound_email_input_email" //修改绑定邮箱-输入邮箱
        const val CHANGE_BOUND_EMAIL_VERIFY_EMAIL =
            "$GROUP/change_bound_email_verify_email" //修改绑定邮箱-验证邮箱
        const val FORGOT_PSW_INPUT_EMAIL = "$GROUP/forgot_psw_input_email" //忘记密码-输入邮箱
        const val FORGOT_PSW_EMAIL_SENT = "$GROUP/forgot_psw_email_sent" //忘记密码-邮件已发送
        const val EDIT_USERNAME = "$GROUP/edit_username"//编辑用户名
        const val EDIT_PERSONAL_PROFILE = "$GROUP/edit_personal_profile"//编辑个人简介
        const val EDIT_PERSONAL_INFO = "$GROUP/edit_personal_info"//编辑个人信息

        const val FEEDBACK = "$GROUP/setting_feedback" //flutter

        const val PRIVACY_SETTINGS = "$GROUP/setting_privacy_settings" //flutter
        const val DELETE_YOUR_ACCOUNT = "$GROUP/delete_your_account" //flutter 无路由
        const val DELETION_CONFIRM = "$GROUP/deletion_confirm" //flutter 无路由
        const val LINK_SOCIAL_GUANG_ACCOUNT = "$GROUP/link_social_guang_account" //连接三方登录账号和Guang账号

        const val LOGIN_FORGET_PASS_EMAIL_SEND = "$GROUP/user_login_forgot_pass_email_sent"

        const val LOGIN_FORGOT_PASS_INPUT_PASS = "$GROUP/user_login_forgot_pass_input_pass"
    }

    /**
     * 消息
     */
    object Message {
        const val GROUP = "/message"
        const val MY_MESSAGE = "$GROUP/my_message" // 消息首页
        const val MESSAGE_LIKE_OR_COMMENT = "$GROUP/message_like_or_comment" // 喜欢消息页或评论消息页
        const val MESSAGE_FOLLOWERS = "$GROUP/message_follower" // 粉丝消息页
        const val MESSAGE_SYSTEM_NOTIFICATION = "$GROUP/message_system_notification" // 系统消息页
        const val MESSAGE_ACTIVITY = "$GROUP/message_activity" // 活动消息页
    }

    /**
     * 冷启动偏好配置
     */
    object PreferenceConfig {
        const val GROUP = "/preferenceconfig"
        const val BRAND_CHOICE = "$GROUP/brand_choice" // 品牌选择
        const val CHOOSE_COMPLETE = "$GROUP/choose_complete" // 选择完成

        const val ARGS_SELECTED_BRANDS = "ARGS_SELECTED_BRANDS" // 已选品牌
        const val ARGS_PFEFERENCE_BRANDS = "ARGS_PFEFERENCE_BRANDS" // 偏好品牌列表
    }

    /**
     * 图搜
     */
    object ImageSearch {

        const val GROUP = "/imgsearch"

        const val PAGE_CAMERA = "$GROUP/camera"

        const val PAGE_RESULT = "$GROUP/img_search_route"

        const val PAGE_BARCODE_RESULT = "$GROUP/barcode_result_route"

        /**
         * 商品条形码
         */
        const val ARGS_PRODUCT_BARCODE = "product_barcode"

        /**
         * 图搜结果文件
         */
        const val ARGS_FILE_PATH = "file_path"

        /**
         * 图搜结果网络图
         */
        const val ARGS_IMG_URL = "img_url"

        /**
         * 内容图搜
         */
        const val ARG_POST_PIC_ID = "post_pic_id"

        /**
         * 页面-找相似
         */
        const val PAGE_FIND_SIMILAR = "$GROUP/find_similar"

    }

    /**
     * 社区
     */
    object Post {
        private const val GROUP = "/post"

        const val PAGE_PIC = "$GROUP/post_pic_detail" // 图文详情
        const val PAGE_TOPIC = "$GROUP/topic_detail" //话题详情
        const val PAGE_HASHTAG = "$GROUP/hashtag_detail" //hashtag
        const val PAGE_PRODUCT_SET = "$GROUP/recommend_good_set" //商品合集详情
        const val PAGE_CONTENT_DELETED = "$GROUP/account_content_deleted" //内容删除页

        const val ARGS_TIP = "tip"
        const val POST_ID = "id"
        const val TRACE_ID = "traceId"
        const val POST_LIST = "listPostMain"
        const val POST = "post"
        const val POST_PAGE = "pageNo"
        const val POST_SEARCH_TYPE = "search_type"
        const val TOPIC_ID = "topicId"

        /**
         * 场景
         * ！！！传[SCENE.value]
         */
        const val ARG_SCENE = "scene"


        @Parcelize
        enum class SCENE(val value: Int) : Parcelable {
            /**
             * 首页
             */
            Discover(0),

            /**
             * 搜索
             */
            SEARCH(1),

            /**
             * 话题/HASHTAG
             */
            TOPIC(2),

            /**
             * 我的喜欢、消息页
             */
            ME(3),

            /**
             * 其它（错误页推荐 ContentDeletedActivity）
             */
            OTHER(4),
        }
    }

    object PostVideo {
        private const val GROUP = "/postvidoe"

        const val PAGE_VIDEO = "$GROUP/post_video_detail" // 视频详情

    }

    /**
     * 商品
     */
    object Product {
        private const val GROUP = "/product"

        const val PAGE_DETAIL = "$GROUP/oneScreenOneCard" //商品详情
        const val PAGE_LINK = "$GROUP/product_web_link" //商品外链

        const val COLLECT = "collect" //是否有收藏商品 bool
        const val COLLECTED = "collected" //是否有收藏商品 int
        const val PRODUCT_ID = "productId" //商品id
        const val TRACE_ID = "traceId"
        const val POST_ID = "postId" //分享商品推荐关联内容id
        const val INDEX = "index" //商品id
        const val STANDARD_SPU_ID = "standardSpuIds" //标品id
        const val PRODUCT = "product" //商品
        const val PRODUCT_SIM_DIALOG = "product_dialog" //商品id
        const val TYPE = "type" //商品类型
        const val MOUTED_PRODUCT_LIST = "productList" //挂载商品列表
    }

    /**
     * 店铺
     */
    object Store {
        private const val GROUP = "/store"
        const val PAGE_HOME = "$GROUP/stores_home_page" //商铺主页
        const val DIALOG_STORE_FOLLOW = "$GROUP/dialog_store_follow" //商铺关注弹窗

        const val PAGE_DISCOUNT_PRODUCTS = "$GROUP/store_discount_products_page" //店铺折扣商品页
        const val PAGE_SEARCH = "$GROUP/stores_search_page" //商铺搜索页
        const val PAGE_MY_MANAGE = "$GROUP/stores_manage_home" // 我的-订阅店铺管理主页
        const val PAGE_MANAGE_BRAND = "$GROUP/brand_manage_home" // 我的-品牌订阅管理主页
        const val PAGE_HOME_RECOMMEND = "$GROUP/recommend_stores_page" //首页-商铺推荐页
        const val PAGE_MANAGE = "$GROUP/stores_manage_page" //商铺、品牌管理页
        const val PAGE_LINK = "$GROUP/stores_link_page" //商铺外链页

        const val STORE_NUM = "storeNum" //商铺订阅页商品数
        const val FOLLOWED = "followed" //是否有订阅店铺
        const val IS_BRAND = "is_brand" //是否有品牌
        const val ID = "id" //店铺id
        const val STORE_ID = "storeId" //店铺id
        const val URL = "url" //店铺url
        const val SUB_OR_NOT = "subOrNot" //店铺订阅情况
        const val STORE_NAME = "name" //店铺名称
        const val STORE_LOGO = "logo" //店铺图标
        const val STORE_DISCOUNT = "discount" //店铺折扣
        const val STORE_DISCOUNT_TIP = "discountTip" //店铺折扣
        const val STORE_DISCOUNT_CODE = "couponCode" //店铺Code
        const val STORE_INFO = "STORE_INFO" //店铺信息
    }

    /**
     * 文本搜索
     */
    object Search {

        const val GROUP = "/search"

        /**
         * 搜索主页
         */
        const val PAGE_SEARCH = "$GROUP/search"

        /**
         * 参数名 ： 底纹词
         * String
         */
        const val ARG_SHADING_WORD = "shading_word"

        /**
         * 参数名：热词
         * 数组
         */
        const val ARG_HOT_WORDS = "hot_words"

        /**
         * 参数：搜索词
         */
        const val ARG_KEY_WORD = "key_word"

        /**
         * 参数：规则引擎id
         */
        const val GOOD_RULE_ID = "goodsRuleId"

        /**
         * 搜索结果
         */
        const val PAGE_SEARCH_RESULT = "$GROUP/search_result"

        const val ARG_SEARCH_RESULT = "search_result"

        /**
         * 商品域搜索
         */
        const val PAGE_SEARCH_GOODS = "$GROUP/search_goods"

        /**
         * 商品类目列表
         */
        const val PAGE_GOODS_CATEGORY = "$GROUP/goods_category"

        /**
         * 三级类目商品结果页
         */
        const val PAGE_CATEGORY_GOODS = "$GROUP/tertiary_category_goods"

//        /**
//         * v1.1 商品一级类目主页
//         */
//        const val PAGE_CATEGORY_MAIN = "$GROUP/category_main"

        /**
         * 场景
         * ！！！传[SCENE.value]
         */
        const val ARG_SCENE = "scene"

        const val ARG_HISTORY_TAG = "history_tag"


        @Parcelize
        enum class SCENE(val value: Int) : Parcelable {
            /**
             * 所有结果, goods/stores/posts/users
             */
            ALL(0),

            /**
             * 默认，goods / brands / stores
             */
            NORMAL(1),

            /**
             * 发现，posts / users
             */
            DISCOVER(2),

            /**
             * 商品，只有 goods
             */
            GOODS(3),

            /**
             * 店铺，只有 stores
             */
            STORES(4),

            /**
             * 品牌，只有 brands
             */
            BRANDS(5),
        }

    }


    object GCONFIG {

        const val GROUP = "/guangconfig"

        /**
         * 配置主页
         */
        const val GUANG_UP_CONFIG = "$GROUP/guang_up_config"


        /**
         * 404
         */
        const val G_NOT_FOUNT = "$GROUP/404"
    }

    /**
     * 我的
     */
    object Mine {
        const val GROUP = "/mine"
        const val PERSON_HOME = "$GROUP/person_hone" // 个人首页
        const val FOLLOW = "$GROUP/follow" // 关注页面
    }

    /**
     * 心愿单
     */
    object Wishlist {
        const val GROUP = "/wishlist"
        const val WISHLIST_ENTRY = "$GROUP/wishlist_entry" // 心愿单创建
        const val CREATE_BOARD = "$GROUP/create_board" // 心愿单创建
        const val WISHLIST_DETAILS = "$GROUP/wishlist_details" // 心愿单详情
        const val WISHLIST_SEARCH = "$GROUP/wishlist_search" // 心愿单搜索
        const val DETAILS_ADD = "$GROUP/details_add" // 心愿单详情添加
    }

    /**
     * Fragment弹窗
     */
    object DialogFragment {
        const val GROUP = "/dialogfragment"
        const val PERSONAL_HOME_OBJECTIVE_MORE_DIALOG =
            "${GROUP}/personal_home_objective_more_dialog" //个人首页-客态-更多弹窗
    }

    /**
     * 品牌
     */
    object Brand {
        const val GROUP = "/brand"
        const val BRAND_COLLECTION = "$GROUP/brand_collections_detail" // 品牌集合
        const val BRAND_ALL = "$GROUP/brand_all" // 全部品牌
        const val BRAND_ALL_SEARCH = "$GROUP/brand_all_search" // 全部品牌搜索
        const val BRAND_DETAIL = "$GROUP/brand_detail" // 品牌奥莱详情页
        const val BRAND_SEARCH = "$GROUP/brand_search" // 品牌奥莱搜索页
        const val DIALOG_CHANGE_VIEW = "$GROUP/brand_dialog_change_view" // 品牌商品修改视图模式弹窗

        const val ARG_brandName = "brandName"//品牌名称
        const val ARG_brandCollectionId = "brandCollectionId"//品牌集 id
        const val ARG_productId = "productId"//首页品牌集展示图片所属商品的 id, 用于后续页面置顶
        const val ARG_BRAND_ID = "brandId"
        const val ARG_BRAND_NAME = "arg_brand_name"
        const val ARG_IS_DISCOUNT_BRAND = "arg_is_discount_brand"
        const val ARG_EXPOSURE_BRAND_IDS = "arg_exposure_brand_ids"
        const val ARG_SIMPLE_VIEW = "arg_simple_view"
    }

    object Widget {
        const val GROUP = "/widget"
        const val WIDGET_SUBSCRIPTION="$GROUP/subscription"

    }

    object SuperStoreDeal {

        const val GROUP = "/super_store_deals"

        const val HOME = "$GROUP/index"

        const val SEARCH = "$GROUP/search"
    }

    object ARG {
        const val ID = "id"
        const val TITLE = "title"
        const val DESC = "desc"
        const val TYPE = "type"
        const val IS_SALE_ZONE = "is_sale_zone"
        const val IMG_URL = "img_url"
        const val USER_INFO = "USER_INFO" //用户信息或者账户信息

        //批量操作
        const val BATCH_PRODUCT = "batch_product"
        const val IS_WISH_LIST = "is_wish_list"
        const val WISH_ID = "wish_id"
        const val EXCLUDE_WISHLIST_ID = "exclude_wishlist_id"
        const val SPM_PAGE_VALUE = "spm_page_value"

    }

    object Extra {

        /**
         * 路由页面需要登录
         */
        const val NEED_LOGIN: Int = 20230426

    }

}